$(document).ready(function(){
	let swi = new Swiper(".cityInd .cityIndTit", {
		slidesPerView:"auto"
	});
	
	// tab点击
	let docmHeight_1 = $(".cityCont .cityInd").offset().top - $(".cityHead").height();
	$(".cityCont .cityIndTit .swiper-slide").click(function(){
		let n = $(this).index();
		$(this).addClass("on").siblings().removeClass("on");
		$(".cityIndCon .list").eq(n).show().addClass("active").siblings().hide().removeClass("active");
		if(n > 1){
			swi.slideTo(n-1, 500);
		}else{
			swi.slideTo(0, 500);
		};
		chart(array);
		//返回第一个图表位置
		let docmHeight = $(".cityCont .cityInd").offset().top - $(".cityHead").height();
		if(docmHeight < 0){
			$('.cityHei').scrollTop(docmHeight_1 + 2);
		}
	});
	// 数组
	let array = [
		{
			"num":["3891个","3748个","3248个","1029个"],
			"text":["互联网/电子商务","多元化业务集团公司","服装/纺织/皮革","网络游戏"]
		},{
			"num":["260,283","252,283","242,283","132,283"],
			"text":["互联网/电子商务","多元化业务集团公司","服装/纺织/皮革","网络游戏"]
		},{
			"num":["260,283","252,283","242,283","162,283","132,283"],
			"text":["外资（欧美）","外资（非欧美）","国企","民营企业","合资"]
		}
	];
	//图表
	function chart(arrBig){
		$.each(arrBig,function(i,val){
			let hta = "";
			let htb = "";
			let arrNum = arrBig[i].num;
			let arrText = arrBig[i].text;
			let arr = [];
			for(var n = 0;n<arrNum.length;n++){
				hta += "<li><span>"+ arrNum[n] +"</span><p></p></li>"
				htb += "<p>"+ arrText[n] +"</p>"
				var a = arrNum[n].replace(/[^0-9]/ig,"");
				arr.push(a);
			};
			let dom = $(".active .chart").eq(i);
			dom.find("ul").html(hta);
			dom.find(".chartText").html(htb);
			for(var n = 0;n<arr.length;n++){
				var j = arr[n]/arr[0]*100;
				dom.find("li").eq(n).animate({height:j + "%"}, 500);
				dom.find("li").eq(n).children("span").animate({opacity:1},500);
			};
		});
	};
	chart(array);
	// 上滑
	function toTop(){
		let sHeight = $(".cityCont .cityInd").offset().top - $(".cityHead").height();
		$(".cityHei").scroll(function(){
			let sTop = $(this).scrollTop();
			if(sTop >= sHeight){
				$(".cityCont .cityInd").addClass("topFix");
			}else{
				$(".cityCont .cityInd").removeClass("topFix");
			}
		});
	};
	toTop();

})